#!/bin/bash
if `which docker > /dev/null`; then
  if [ $# -eq 0 ]; then
    docker run -v $PWD:/scan -it licensefinder/license_finder
  else
    escaped_params=""
    for p in "$@"; do
      escaped_params="$escaped_params \"$p\""
    done
    if [[ $escaped_params =~ "&&" ]]; then
      command=${escaped_params:2:${#escaped_params}-3}
    else
      command=$escaped_params
    fi
    docker run -v $PWD:/scan -it licensefinder/license_finder /bin/bash -lc "cd /scan && $command"
  fi
else
  echo "You do not have docker installed. Please install it:"
  echo "    https://docs.docker.com/engine/installation/"
  exit 1
fi
